package com.ruoyi.club.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.club.domain.CmsClubStrip;
import com.ruoyi.club.service.ICmsClubStripService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 俱乐部剑道Controller
 * 
 * @author 王向阳
 * @date 2024-10-06
 */
@Controller
@RequestMapping("/club/strip")
public class CmsClubStripController extends BaseController
{
    private String prefix = "club/strip";

    @Autowired
    private ICmsClubStripService cmsClubStripService;

    @RequiresPermissions("club:strip:view")
    @GetMapping()
    public String strip()
    {
        return prefix + "/strip";
    }

    /**
     * 查询俱乐部剑道列表
     */
    @RequiresPermissions("club:strip:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CmsClubStrip cmsClubStrip)
    {
        startPage();
        List<CmsClubStrip> list = cmsClubStripService.selectCmsClubStripList(cmsClubStrip);
        return getDataTable(list);
    }

    /**
     * 导出俱乐部剑道列表
     */
    @RequiresPermissions("club:strip:export")
    @Log(title = "俱乐部剑道", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CmsClubStrip cmsClubStrip)
    {
        List<CmsClubStrip> list = cmsClubStripService.selectCmsClubStripList(cmsClubStrip);
        ExcelUtil<CmsClubStrip> util = new ExcelUtil<CmsClubStrip>(CmsClubStrip.class);
        return util.exportExcel(list, "俱乐部剑道数据");
    }

    /**
     * 新增俱乐部剑道
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存俱乐部剑道
     */
    @RequiresPermissions("club:strip:add")
    @Log(title = "俱乐部剑道", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CmsClubStrip cmsClubStrip)
    {
        return toAjax(cmsClubStripService.insertCmsClubStrip(cmsClubStrip));
    }

    /**
     * 修改俱乐部剑道
     */
    @GetMapping("/edit/{stripid}")
    public String edit(@PathVariable("stripid") Long stripid, ModelMap mmap)
    {
        CmsClubStrip cmsClubStrip = cmsClubStripService.selectCmsClubStripById(stripid);
        mmap.put("cmsClubStrip", cmsClubStrip);
        return prefix + "/edit";
    }

    /**
     * 修改保存俱乐部剑道
     */
    @RequiresPermissions("club:strip:edit")
    @Log(title = "俱乐部剑道", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CmsClubStrip cmsClubStrip)
    {
        return toAjax(cmsClubStripService.updateCmsClubStrip(cmsClubStrip));
    }

    /**
     * 删除俱乐部剑道
     */
    @RequiresPermissions("club:strip:remove")
    @Log(title = "俱乐部剑道", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cmsClubStripService.deleteCmsClubStripByIds(ids));
    }
}
